﻿using MoveView.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MoveView.MyMath
{
    static class Constants
    {
        public const double PI = 3.141592653589793238462643;
        public const double DTOR = 0.0174532925;
        public const double RTOD = 57.2957795;

        public static XYZ Crossproduct(XYZ p1, XYZ p2)
        {
            XYZ p3 = new XYZ();
            p3.x = p1.y * p2.z - p1.z * p2.y;
            p3.y = p1.z * p2.x - p1.x * p2.z;
            p3.z = p1.x * p2.y - p1.y * p2.x;
            return p3;
        }

        public static void Normalize(ref XYZ p)
        {
            double length;
            length = Math.Sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
            if (length != 0)
            {
                p.x /= length;
                p.y /= length;
                p.z /= length;
            }
            else
            {
                p.x = 0;
                p.y = 0;
                p.z = 0;
            }
        }
    }
}
